#include "gtest/gtest.h"

#include "Graph.h"
#include "FloydWarshall.h"

class FloydWarshallTest : public ::testing::Test {
	protected:
		virtual void SetUp() {
		}
		virtual void TearDown() {
		}

	public:
};

TEST_F(FloydWarshallTest, Predecessor_OK) {
	Graph g(4, false);
	g.addEdge(0, 1, 50);
	g.addEdge(0, 2, 10);
	g.addEdge(0, 3, 30);
	g.addEdge(2, 3, 15);

	FLWAR sut(g);
	sut.allPairsShortest();

	vector<vector<int> > expectedPred;
	expectedPred.resize(4);
	expectedPred[0].push_back(-1);
	expectedPred[0].push_back(0);
	expectedPred[0].push_back(0);
	expectedPred[0].push_back(2);
	expectedPred[1].push_back(1);
	expectedPred[1].push_back(-1);
	expectedPred[1].push_back(0);
	expectedPred[1].push_back(2);
	expectedPred[2].push_back(2);
	expectedPred[2].push_back(0);
	expectedPred[2].push_back(-1);
	expectedPred[2].push_back(2);
	expectedPred[3].push_back(2);
	expectedPred[3].push_back(0);
	expectedPred[3].push_back(3);
	expectedPred[3].push_back(-1);

	ASSERT_EQ(expectedPred, sut.getPredecessor());
}

TEST_F(FloydWarshallTest, Distance_OK) {
	Graph g(4, false);
	g.addEdge(0, 1, 50);
	g.addEdge(0, 2, 10);
	g.addEdge(0, 3, 30);
	g.addEdge(2, 3, 15);

	FLWAR sut(g);
	sut.allPairsShortest();

	vector<vector<int> > expectedDistance;
	expectedDistance.resize(4);
	expectedDistance[0].push_back(0);
	expectedDistance[0].push_back(50);
	expectedDistance[0].push_back(10);
	expectedDistance[0].push_back(25);
	expectedDistance[1].push_back(50);
	expectedDistance[1].push_back(0);
	expectedDistance[1].push_back(60);
	expectedDistance[1].push_back(75);
	expectedDistance[2].push_back(10);
	expectedDistance[2].push_back(60);
	expectedDistance[2].push_back(0);
	expectedDistance[2].push_back(15);
	expectedDistance[3].push_back(25);
	expectedDistance[3].push_back(75);
	expectedDistance[3].push_back(15);
	expectedDistance[3].push_back(0);

	ASSERT_EQ(expectedDistance, sut.getDistance());
}

